package com.example.kotlinstudy.控制流程

fun main() {
    val a = 2
    val b = 2
    var max = a
    if (a < b) max = b
    if (a > b) {
        max = a
    } else {
        max = b
    }
    max = if (a > b) a else b
    val maxLimit = 1
    val maxOrLimit = if (maxLimit > a) maxLimit else if (a > b) a else b
    println("max is $max")
    println("maxOrLimit is $maxOrLimit")

    val max002 = if (a > b) {
        print("Choose a")
        a
    } else {
        print("Choose b")
        b
    }
    println(maxOrLimit)
}

//分支是简单布尔值
fun test() {
    val y = 1
    val x = 1
    fun Int.isOdd(): Boolean {
        return this%2 != 0
    }
    fun Int.isEven(): Boolean {
        return this%2 == 0
    }
    when {
        x.isOdd() -> print("x is odd")
        y.isEven() -> print("y is even")
        else -> print("x+y is odd")
    }
}


enum class Bit {
    ZERO, ONE
}

val numericValue = when (Bit.ONE) {
    Bit.ONE -> 1
    Bit.ZERO -> 0
    //else不需要，因为枚举类型都覆盖了
}

enum class Color {
    RED, GREEN, BLUE
}